/*
 * Copyright © 2016 Cask Data, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

@import '../styles/variables.less';
@import '../../node_modules/@bower_components/bootstrap/less/mixins.less';
@import '../styles/themes/cdap/mixins.less';

@tracker-grey: #999999;
@border-color: #cdcdcd;
@search-font-color: #666666;
@title-font-color: #333333;
@active-font: #363945;
@filter-sidebar-background-color: #eeeeee;
@tag-bg: #b9c1d9;
@well-bg: #d3d3d3;
@search-top-bar-container-size: 60px;
@navbar-size: 50px;
@entity-detail-top-bar-size: 50px;
@tracker-blue: #0077dc;
@tips-highlight-color: @green-02;

body { background-color: #e5e5e5; }

body[class*='state-tracker'] {
  main.container {
    margin: 0;
    margin-top: 50px;
    width: 100%;
    overflow-x: hidden;
    // FIXME: ad-hoc - This is added here because of the resource center button.
    min-height: 500px;
    overflow-y: auto;
    padding: 0 0 15px 0;

    h1,
    h2,
    h3,
    h4,
    h5,
    h6 { font-weight: 500; }

    &.iframe { margin-top: 0; }
  }

  .alerts { top: 50px; }

  footer.app-footer { border-top: 1px solid @border-color; }

  .tooltip {
    &.tracker-tooltip {
      .tooltip-inner {
        border: none;
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
        font-size: 12px;
        color: white;
        background-color: black;
      }
      &.top {
        .tooltip-arrow { border-top-color: black; }
      }
      &.right {
        .tooltip-arrow { border-right-color: black; }
      }
    }
  }
}

body.state-tracker-home.state-tracker {
  background-color: white;

  .tracker-content { padding: 0 15px; }

  div.tracker-search.form-group {
    margin-top: 150px;

    .form-control {
      height: 50px;
      border-radius: 0;

      &:focus {
        border-width: 2px;
        box-shadow: none;
      }
    }

    span {
      line-height: 50px;
      font-size: 18px;
      color: @title-font-color;
      margin-right: 8px;
    }
  }

  .search-tips {
    .title {
      color: @tips-highlight-color;
      font-size: 18px;
      margin-top: 45px;
      margin-bottom: 10px;
      border-bottom: 1px solid @grey-03;
    }

    .subtitle { font-size: 15px; }

    .search-tips-container {
      > div {
        margin: 20px 0;
      }
      .search-tip-highlight {
        color: @tips-highlight-color;
      }
    }
  }
}

body.state-tracker {
  background-color: #e5e5e5;

  .content-loading { margin-top: 150px; }

  .tracker-top-search {
    background-color: #dfdfdf;
    border-bottom: 1px solid @border-color;
    display: flex;
    align-items: center;
    height: 60px;
    position: relative;

    .tracker-search-bar {
      width: 500px;
      padding: 10px;
      margin-left: 15px;
      display: inline-block;
    }

    .try-star-search { color: #777777; }

    .form-group {
      margin-bottom: 0;

      .form-control {
        height: 40px;
        color: @search-font-color;
      }

      span {
        line-height: 40px;
        font-size: 18px;
        color: @tracker-grey;
        margin-right: 8px;
      }
    }
  }

  .tracker-no-result {
    margin-top: 150px;
    p {
      font-size: 18px;
      color: @search-font-color;
    }
  }

  .tracker-container {
    .title-bar {
      border-bottom: 1px solid @border-color;
      height: 50px;
      line-height: 50px;
      padding: 0 15px;

      h3 {
        font-size: 14px;
        font-weight: bold;
        color: @title-font-color;
        margin: 0;
        display: inline-block;
      }
    }

    .tracker-filters { padding: 0 20px; }

    .tracker-filter-sidebar {
      width: 300px;
      position: absolute;
      background-color: @filter-sidebar-background-color;
      top: @navbar-size + @search-top-bar-container-size + 1;
      bottom: 53px;
      border-right: 1px solid @border-color;

      h4 {
        font-size: 13px;
        font-weight: 500;
        margin-top: 20px;
        color: @title-font-color;
      }

      .tracker-filters {
        .filter-show-all,
        .only-button {
          color: var(--brand-primary-color);
          text-decoration: underline;
        }

        .filter-show-all {
          margin-left: 10px;
          cursor: pointer;
        }

        .checkbox {
          margin: 0 -20px;
          padding: 3px 20px;

          &.hover { background-color: #dfdfdf; }

          .only-button { margin-right: 10px; }
        }

        label {
          font-weight: 500;
          color: @tracker-grey;
          user-select: none;
          width: 100%;

          &.active { color: @active-font; }

          input[type='checkbox'] { margin-top: 3px; }
        }
      }
    }

    .tracker-search-results {
      position: absolute;
      top: @navbar-size + @search-top-bar-container-size + 1;
      bottom: 53px;
      left: 300px;
      right: 0;
      background-color: white;

      .title-bar {
        background-color: @filter-sidebar-background-color;
        h3 { margin-right: 5px; }
        .btn.btn-grey {
          margin-right: 15px;
          background-color: #cccccc;
          color: @active-font;
          padding: 4px 10px 7px; // aligning text with Sort by
          font-weight: 500;
          .caret { margin-left: 20px; }
        }
        .dropdown-menu > li > a {
          &:hover,
          &:focus { cursor: pointer; }
        }
        .results-count {
          display: inline-block;
          color: @tracker-grey;
          font-size: 12px;
        }
      }

      .no-search-results {
        margin-top: 150px;
        h4 { font-weight: 500; }
      }

      .results-list {
        overflow-y: auto;
        height: 100%;
        padding-bottom: 51px; // This is to offset the top sort panel

        h4,
        h5 { font-weight: 500; }
        p,
        .creation-time { color: @tracker-grey; }
        h4,
        h4 a {
          font-size: 16px;
          color: @title-font-color;
          margin-bottom: 5px;
        }

        h5 {
          font-size: 12px;
          color: @tracker-grey;
          margin: 0 0 5px 0;

          [class*="icon-"] { font-size: 12px; }
          .text-dark { color: @title-font-color; }
        }

        .row {
          border-bottom: 1px solid @border-color;
          padding: 0 15px 15px;
          display: block;
        }

        my-truth-meter {
          display: inline-block;
        }
        .creation-time {
          margin-top: 5px;
        }
      }
    }
  }

  .time-range-picker-group {
    .dropdown-menu { margin: 0; }
  }

  ul.pagination {
    margin-top: 0;
    > li {
      a,
      a:hover,
      a:focus,
      span {
        background-color: transparent;
        border: 0;
        color: @tracker-blue;
      }
      a,
      span { padding: 6px; }
      a {
        z-index: 0;
        &:focus { outline: 0; }
      }
      &.active,
      &.disabled {
        a,
        a:hover,
        a:focus,
        span {
          background-color: transparent;
          border: 0;
          color: @tracker-grey;
        }
      }
    }
  }

  table.table {
    tr.empty-row > td { height: 38px; }
  }

  .tag {
    border-radius: 4px;
    color: white;
    font-size: 12px;
    padding: 5px 10px;
    &:focus { outline: 0; }
    &.user {
      background-color: @tag-bg;
      color: @title-font-color;
      span.fa-times {
        -webkit-text-stroke: 1px @tag-bg;
        color: @title-font-color;
      }
    }
    span.fa-times {
      color: @well-bg;
      font-size: 11px;
      position: relative;
      bottom: -1px;
    }
  }

  // Complex Schema styling
  .tab-header-inner { background-color: #eeeeee; }

  my-complex-schema my-embedded-schema-selector div.tab-toggle.expanded:before { background-color: transparent; }

  cask-resource-center-button {
    .cask-resourcecenter-button {
      position: absolute;
      top: 30px;
    }
  }
}

body.state-tracker-detail-entity {
  .tracker-entity-top-bar {
    display: table;
    height: 50px;
    width: 100%;
    border-bottom: 1px solid @border-color;
    background-color: white;

    .back-button,
    .entity-detail,
    .tab-options,
    .action-button {
      height: 100%;
      vertical-align: middle;
      display: table-cell;
    }

    .back-button {
      width: 50px;
      border-right: 1px solid @border-color;
      cursor: pointer;
    }

    .entity-detail {
      padding-left: 10px;
      padding-right: 30px;
      width: 200px;
      h3 {
        font-size: 16px;
        margin: 0;
        white-space: nowrap;
      }
      span {
        color: @tracker-grey;
        font-size: 12px;
      }
      .entity-type { margin-top: 3px; }

      &.offset { padding-left: 20px; }
    }

    .tab-options {
      ul {
        margin-bottom: 0;
        margin-left: 20px;
        height: 50px;
        overflow-y: hidden;
      }
      li {
        font-size: 14px;
        font-weight: 500;
        margin-right: 40px;
        padding: 0;
        height: 100%;
        line-height: 50px;

        &.active {
          a { color: @title-font-color; }
          border-bottom: 4px solid var(--brand-primary-color);
        }
        a {
          color: @tracker-grey;
          text-decoration: none;
          vertical-align: middle;
        }
      }
    }

    .action-button { padding-right: 15px; }
  }

  main.container {
    h4 {
      font-size: 14px;
      color: @title-font-color;
    }

    .no-properties-message {
      margin-top: 150px;
      h4 { color: @tracker-grey; }
    }
  }

  .entity-container { padding: 20px; }

  .entity-detail-tags-column,
  .entity-detail-schema-column,
  .entity-detail-properties-column {
    position: absolute;
    top: @navbar-size + @search-top-bar-container-size + 1 + @entity-detail-top-bar-size + 1;
    bottom: 53px;
    box-sizing: border-box;
    overflow-y: auto;

    .table {
      border-top: 0;
      border-right: 0;
      border-left: 0;

      th:first-child,
      td:first-child { border-left: 0; }

      th:last-child,
      td:last-child { border-right: 0; }

      tr:first-child {
        td { border-top: 0; }
      }
    }
  }

  .entity-detail-tags-column,
  .entity-detail-schema-column {
    width: 30%;
    border-right: 4px solid @border-color;
  }

  .entity-detail-tags-column {
    left: 0;
    background-color: @filter-sidebar-background-color;
    h4 { margin-top: 0; }

    .invalid-tag {
      border: 1px solid @brand-danger;
    }

    .user-tags .tags-container {
      span:not(.fa) {
        display: inline-block;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 90%;
        vertical-align: middle;
      }
    }

    .system-tags .tags-container div {
      background-color: #929fbc;
      color: @title-font-color;
    }

    div.tags-container {
      margin-bottom: 40px;
      div.tag {
        border-radius: 4px;
        display: inline-block;
        line-height: 1.1;
        margin-right: 5px;
        margin-bottom: 5px;
        max-width: 48%;
        padding: 6px 8px;
        span:hover,
        span:focus { cursor: pointer; }
      }
    }

    div.add-tag {
      a.btn {
        .cask-btn(@background: #ffffff, @border: 1px solid @border-color, @border-radius: 4px, @color: @cdap-button, @font-size: 11px, @padding: 5px 8px);
        transition: all 0.2s ease-in-out;
        &:hover,
        &:focus {
          background-color: @tracker-blue;
          color: #ffffff;
          outline: 0;
        }
      }
    }

    .tag-input {
      width: 150px;
      .form-control {
        background-color: transparent;
        height: 27px;
        border-radius: 4px;
        line-height: 1.3;
        margin-bottom: 5px;
        transition: border-color 0.2s ease-in-out;
        &:focus {
          border-color: @border-color;
          box-shadow: none;
        }
      }
      &.invalid .form-control { border-color: @alert-danger-bg; }
      + p.text-danger {
        color: @alert-danger-bg;
        font-weight: 500;
      }
    }
  }

  .title-bar {
    height: 50px;
    border-bottom: 1px solid @border-color;
    background-color: @filter-sidebar-background-color;
    line-height: 50px;
    display: table;
    width: 100%;

    h4 {
      margin: 0;
      vertical-align: middle;
    }
  }

  .table {
    margin-top: 0;
    width: 100%;

    th,
    td { font-size: 13px; }
    td { word-break: break-word; }
    span.fa { color: @tracker-grey; }
    tbody tr:nth-child(2n) {
      background-color: darken(@filter-sidebar-background-color, 1%);
    }
  }

  .entity-detail-schema-column {
    left: 30%;
    background-color: @filter-sidebar-background-color;

    .title-bar {
      h4 {
        display: table-cell;
        padding-left: 10px;
      }
    }
    .column-content {
      h4 {
        font-weight: 500;
        font-size: 13px;
      }
    }
    .table {
      td:last-child { width: 15%; }
      td:first-child { width: 45%; }
      td:nth-child(2) { width: 40%; }
    }

    .complex-type {
      cursor: pointer;
      text-decoration: underline;
    }
  }

  .entity-detail-properties-column {
    width: 40%;
    right: 0;
    background-color: @filter-sidebar-background-color;

    .title-bar .title-tab {
      display: table-cell;
      vertical-align: middle;
      width: 50%;
      cursor: pointer;
      h4 { color: @title-font-color; }

      &:first-child { border-right: 1px solid @border-color; }

      &.active {
        background-color: white;
        h4 { color: @tracker-grey; }
      }
    }

    .table {
      th {
        background-color: @filter-sidebar-background-color;
        border-bottom-width: 1px;
      }
      tbody > tr {
        &:nth-of-type(odd) { background-color: #ffffff; }
        &:nth-of-type(even) { background-color: @filter-sidebar-background-color; }
      }
      td {
        vertical-align: middle;
        &.action { padding: 0; }
        &:first-child {
          color: @title-font-color;
          width: 30%;
        }
        &:last-child { width: 50px; }
        pre {
          background: none;
          border: none;
          margin: 0;
          padding: 0;
          width: 70%;
        }
        .btn {
          width: 100%;
          height: 39px;
          border: none;
          border-radius: 0;
          background-color: transparent;

          &.plus { background-color: white; }
        }
      }

      .empty-row { height: 39px; }
      .input-row {
        @row-height: 39px;

        height: @row-height;

        td { padding: 0; }
        .form-control {
          height: @row-height;
          width: 100%;
          border: none;
          border-radius: 0;

          &:focus {
            border: 1px solid var(--brand-primary-color);
            box-shadow: none;
          }
        }
      }
    }

    .column-content {
      position: absolute;
      top: 50px;
      bottom: 0;
      left: 0;
      right: 0;

      .table-container { height: 100%; }
    }
  }
}

body.state-tracker-detail-entity-lineage {
  .time-range-container {
    padding-top: 20px;
    padding-left: 20px;
  }

  .field-level-lineage-link {
    margin-right: 25px;
  }
}
